//package com.conf.redis;
//
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.redis.connection.RedisConnectionFactory;
//import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.data.redis.serializer.GenericToStringSerializer;
//import org.springframework.data.redis.serializer.StringRedisSerializer;
//import redis.clients.jedis.JedisPoolConfig;
//
//@Configuration
//public class RedisConfig {
//    @Value("${spring.redis.host}")
//    private String host;
//    @Value("${spring.redis.port}")
//    private int port;
//    @Value("${spring.redis.database}")
//    private int index;
//
//    @Bean
//    public JedisPoolUtil CreateJedisPoolUtil() {
//        JedisPoolUtil jedisPoolUtil = new JedisPoolUtil(host, port, index,
//                2000, 500, 50);
//        JedisPoolConfig poolConfig = new JedisPoolConfig();
//        return jedisPoolUtil;
//    }
//
//    /**
//     * redis操作模板
//     * 统一设置key的序列化方式为String
//     *
//     * @param redisConnectionFactory
//     * @return
//     */
//    @Bean
//    public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
//        RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
//        redisTemplate.setConnectionFactory(redisConnectionFactory);
//        redisTemplate.setKeySerializer(new StringRedisSerializer());
//        return redisTemplate;
//    }
//    @Bean("stringTemplate")
//    public RedisTemplate redisTemplateString(RedisConnectionFactory redisConnectionFactory){
//        RedisTemplate redisTemplate = new RedisTemplate();
//        redisTemplate.setConnectionFactory(redisConnectionFactory);
//        redisTemplate.setKeySerializer(new StringRedisSerializer());
//        redisTemplate.setValueSerializer(new StringRedisSerializer());
//
//        return redisTemplate;
//    }
//
//    @Bean("redisTemplate")
//    public RedisTemplate advRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
//        RedisTemplate redisTemplate = new RedisTemplate<>();
//        redisTemplate.setConnectionFactory(redisConnectionFactory);
//        redisTemplate.setKeySerializer(new StringRedisSerializer());
//        redisTemplate.setHashKeySerializer(new GenericToStringSerializer<>(Long.class));
//        redisTemplate.setHashValueSerializer(new GenericToStringSerializer<>(Long.class));
//        redisTemplate.setValueSerializer(new GenericToStringSerializer<>(Long.class));
//        return redisTemplate;
//    }
//
//    @Bean("airPriceRedisTemplate")
//    public RedisTemplate airPriceRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
//        RedisTemplate redisTemplate = new RedisTemplate<>();
//        redisTemplate.setConnectionFactory(redisConnectionFactory);
//        redisTemplate.setKeySerializer(new StringRedisSerializer());
//        redisTemplate.setHashKeySerializer(new GenericToStringSerializer<>(String.class));
//        redisTemplate.setHashValueSerializer(new GenericToStringSerializer<>(Long.class));
//        redisTemplate.setValueSerializer(new GenericToStringSerializer<>(String.class));
//
//        return redisTemplate;
//    }
//}
